<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAppVersionsTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('app_versions', function (Blueprint $table) {
            $table->increments('id');
            $table->enum('app_name', ['ALADDIN'])->comment('app名字');
            $table->unsignedTinyInteger('app_id')->default('1')->comment('手机系统类型：1-Android，2-iOS');
            $table->string('version_id')->default('0')->comment('大版本号id');
            $table->string('version_mini')->default('0')->comment('小版本号');
            $table->string('version_code')->default('0')->comment('版本标识 如：109');
            $table->string('version_name')->default('0')->comment('版本名称 如：1.0.9');
            $table->unsignedTinyInteger('type')->default('1')->comment('是否升级  1－用户选择是否升级，2－强制用户升级');
            $table->string('apk_url')->nullable()->default(null)->comment('Android APP下载地址');
            $table->string('download_url')->nullable()->default(null)->comment('app分发平台下载地址');
            $table->string('upgrade_point')->nullable()->default(null)->comment('升级提示');
            $table->unsignedTinyInteger('status')->default('1')->comment('状态：0-不启用 1-启用');
            $table->timestamp('time')->comment('更新时间');
        });
        \Illuminate\Support\Facades\DB::insert('INSERT INTO app_versions(`app_id`, `app_name`, `version_code`, `version_name`, `apk_url`, `download_url`, `upgrade_point`, `time`) VALUES(?, ?, ?, ? ,?, ? ,? ,?)', ['1', 'ALADDIN', '100', '1.0.0', 'http://', 'https://', '检测到有新版本了，请您更新！', \Carbon\Carbon::now()]);
        \Illuminate\Support\Facades\DB::insert('INSERT INTO app_versions(`app_id`, `app_name`, `version_code`, `version_name`, `download_url`, `upgrade_point`, `time`) VALUES(?, ?, ?, ? ,?, ? ,?)', ['2', 'ALADDIN', '100', '1.0.0', 'https://', '检测到有新版本了，请您更新！', \Carbon\Carbon::now()]);
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('app_versions');
    }
}
